﻿@using Volo.Abp.UI.Navigation
@{
    var elementId = MenuItem.ElementId ?? "MenuItem_" + MenuItem.Name.Replace(".", "_");
    var cssClass = string.IsNullOrEmpty(MenuItem.CssClass) ? string.Empty : MenuItem.CssClass;
    var url = string.IsNullOrEmpty(MenuItem.Url) ? "#" : MenuItem.Url;
}
@if (MenuItem.IsLeaf)
{
    if (MenuItem.Url != null)
    {
        <li class="nav-item @cssClass" disabled="@MenuItem.IsDisabled">
            <NavLink class="nav-link" href="@url" id="@elementId">
                @if (MenuItem.Icon != null)
                {
                    if (MenuItem.Icon.StartsWith("fa"))
                    {
                        <i class="@MenuItem.Icon"></i>
                    }
                }
                @MenuItem.DisplayName
            </NavLink>
        </li>
    }
}
else
{
    <li class="nav-item">
        <div class="dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="@elementId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                @if (MenuItem.Icon != null)
                {
                    if (MenuItem.Icon.StartsWith("fa"))
                    {
                        <i class="@MenuItem.Icon"></i>
                    }
                }
                @MenuItem.DisplayName
            </a>
            <div class="dropdown-menu border-0 shadow-sm" aria-labelledby="@elementId">
                @foreach (var childMenuItem in MenuItem.Items)
                {
                    <NavMenuItem MenuItem="@childMenuItem" />
                }
            </div>
        </div>
    </li>

}
@code {
    [Parameter]
    public ApplicationMenuItem MenuItem { get; set; }
}
